package com.currency.core;

import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

public class PrintQueue {
	private final Semaphore mSemaphore;

	public PrintQueue() {
		mSemaphore = new Semaphore(3);
	}

	public void printJob(Object object) {
		try {
			mSemaphore.acquire();
			if (object != null) {
				System.out.println("current" + System.currentTimeMillis()
						+ "--------" + object.toString());
			}
			TimeUnit.SECONDS.sleep(1);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			mSemaphore.release();
		}

	}

}
